package com.viewfin.common.strategy.Conservative.utils;

import com.viewfin.common.except.L0Exception;
import com.viewfin.common.except.L1Exception;
import com.viewfin.common.strategy.BaseRunable;

public class SimpleRunable_Trade extends BaseSimpleRunable {


    public SimpleRunable_Trade(Boolean flag, Object params) {
        super(flag, params);
    }

    @Override
    public void run() {

        int count =0;

        try {

            while (flag){
                //如果 根据开关进行循环执行
//            while (flag) {
//
//                //逻辑
//
//                //同步redis中开关
//            }

                System.out.println("运行次数:"+count+"次");

                count++;

                if(count==100){
                    throw new L0Exception();
                }else if (count == 200){
                    throw new L1Exception();
                }




            }


        } catch (L0Exception exL0) {

            System.out.println("发生exL0级别错误,系统重启");

            SimpleRunable_Trade newSimpleRunable = new SimpleRunable_Trade(flag, params);

            new Thread(newSimpleRunable).start();

        } catch (L1Exception exL1) {
            System.out.println("发生exL1级别错误,发送邮件告知;系统退出");

           //模拟邮件发送
            System.out.println("邮件发送中.....");
            System.out.println("邮件发送完毕！");

        }





    }
}
